#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

class student{
public:
	int id;
	int chinese;
	int math;
	int english;
	int score;
};

bool operator<(student a,student b){
	if(a.score<b.score)return true;
	if(a.score==b.score&&a.chinese<b.chinese)return true;
	if(a.score==b.score&&a.chinese==b.chinese&&a.id>b.id)return true;
	return false;
}
int main(void){
	vector<student> data;
	student input;
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>input.chinese>>input.math>>input.english;
		input.id=i;
		input.score=input.chinese+input.math+input.english;
		data.push_back(input);
	}
	sort(data.begin(),data.end());
	for(int i=data.size()-1;i>data.size()-6;i--){
		cout<<data[i].id<<' '<<data[i].score<<endl;
	}
	return 0;
}

